// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.0

Item {
    id: listItem

    signal clicked
    property alias pressed: mouseArea.pressed

    height: Math.max(100, addressText.height + statusText.height + dateText.height + 20)
    width: parent.width

    BorderImage {
        id: background
        anchors.fill: parent
        anchors.leftMargin: -16
        anchors.rightMargin: -16
        visible: mouseArea.pressed
        source: "image://theme/meegotouch-panel-background-pressed"
    }

    Column {
        visible: index > 0
        height: 6
        width: parent.width
        anchors.bottom: parent.top
        Rectangle {
            color: "lightgray"
            height: 1
            width: parent.width
        }
        Rectangle {
            width: parent.width
            height: 1
            color: "white"
        }
    }

    Row {
        anchors.fill: parent
        spacing: 10

        Image {
            id: icon
            height: 100
            width: 100
            fillMode: Image.PreserveAspectCrop
            source: image
            clip: true
            anchors.verticalCenter: parent.verticalCenter

            BusyIndicator {
                anchors.centerIn: parent
                visible: parent.status == Image.Loading
                running: parent.status == Image.Loading
            }
        }

        Column {
            width: parent.width - icon.width - (moreIndicator.visible ? moreIndicator.width : 0) - 20
            Text {
                id: addressText
                width: parent.width
                wrapMode: Text.WordWrap
                font.family: "Nokia Pure Text"
                font.pixelSize: 20
                text: address
            }
            Label {
                id: statusText
                font.family: "Nokia Pure Text Light"
                font.pixelSize: 18
                color: "gray"
                text: status
            }
            Row {
                width: parent.width
                Label {
                    id: dateText
                    width: parent.width - 28
                    anchors.verticalCenter: parent.verticalCenter
                    font.pixelSize: 18
                    font.italic: true
                    color: "gray"
                    text: date
                }
                Image {
                    source: "../../images/" + type + ".png"
                    width: 28
                    height: 28
                }
            }
        }

        MoreIndicator {
            id: moreIndicator
            visible: false
            anchors.verticalCenter:  parent.verticalCenter
        }
    }

    MouseArea {
        id: mouseArea;
        anchors.fill: parent
        onClicked: {
            listItem.clicked();
        }
    }
}
